<?php
/**
 * Asiaclassified
 *
 * @category   Ac
 * @package    Ac
 * @copyright  Copyright (c) 2010 Asiaclassified. (http://www.asiaclassifies.com)
 */


class Listing_Form_PostAnAddForm extends Ac_Form
{
	
	public function translate($ad = NULL, $translateFields , $classname){
	
	
		if (Zend_Registry::get('current_language') == 'en'){
			if ($ad->ad_type == -1) {
				$ad->ad_type = Model_Listing::ORIGINAL_LANGUAGE_EN;
			}
			$ft = 'en';
			$tt = 'zh-TW';
			
			foreach($translateFields as $v => $r){
				$ad->{$v} = $this->getValue($v);
				
				if (empty($ad->{str_replace('en','tc', $v)})){
					if($v == 'cn_en' || $v == 'tl_en'){
						$ad->{str_replace('en','tc', $v)} = $this->getValue($v);
					}else {
						$ad->{str_replace('en','tc', $v)} = Ac_Translation::execute($this->getValue($v), $tt, $ft);
					}
				}
			}
				$ad->st_en = $this->getValue('st_en');
				if (empty($ad->st_tc)){
					$ad->st_tc = $this->getValue('st_en');
				}
		

		} else {
			if ($ad->ad_type == -1) {
				$ad->ad_type = Model_Listing::ORIGINAL_LANGUAGE_TC;
			}
			$ft = 'zh-TW';
			$tt = 'en';		
			
			foreach($translateFields as $v => $r){
				$ad->{str_replace('en','tc', $v)} = $this->getValue($v);
				
				if (empty($ad->{$v})){
					if($v == 'cn_en' || $v == 'tl_en'){
						$ad->{$v} = $this->getValue($v);	
					}else {
						$ad->{$v} = Ac_Translation::execute($this->getValue($v), $tt, $ft);
					}
				}
			}
			
				$ad->st_tc = $this->getValue('st_en');
				if (empty($ad->st_en)){
					$ad->st_en = $this->getValue('st_en');
				}
			
			

		}
	
	}
	
}



?>